/**
 * Copyright (C) 2015-2018 IQIYI
 * All rights reserved.
 *
 * AUTHOR(S)
 * 王海斌
 *   E-mail: wanghaibin@qiyi.com
 * 
 * VERSION
 *   Sat 30 Jun 2018 02:54:49 PM CST
 */

#include <string>
#include <stdio.h>

int main(int argc, char *argv[])
{
    //std::string key="/\\\\///bbb/ccc/sdfs////\\\\";    
    std::string key="/\\\\///////\\\\";    
    printf("key=%s\n", key.c_str());
    char & lastChar = key.at(key.length()-1);
    while('/'==lastChar || '\\'==lastChar) {
        key = key.substr(0, key.length()-1);
        if(key.empty()) {
            break;
        } 
        lastChar = key[key.length()-1];
    }
    if(!key.empty()) {
        char & firstChar = key[0];
        while('/'==firstChar || '\\'==firstChar) { 
            key = key.substr(1);
            if(key.empty()) {
                break;
            }
            firstChar = key[0];
        }
    }
    printf("new key=%s, len=%d\n", key.c_str(), key.length());
    return 0;
}
